<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<div id="dialogDeleteOrg"></div>
<div class="v-row v-border-bottom" style="padding-top: 10px;">
	<div class="v-row-left" style="margin-left: 10px;">
		<span class="v-title">
			<spring:message  code="project.add.member" />
		</span>
	</div>	
</div>          		
<div class="v-row">
	<div class="v-row-left">							 																
		<fieldset>
	    <legend><spring:message  code="employee.rank"/></legend>
	    <select  style="width:150px;" name="rankId">	
            <option value="0"><spring:message  code="all"/></option>
            <c:forEach items="${bean.ranks}" var="rank">
				<c:choose>
					<c:when test="${rank.rankid == bean.rankId}">
                        <option value="${rank.rankid}" selected="selected">${rank.name}</option>
					</c:when>
					<c:otherwise>
						<option value="${rank.rankid}">${rank.name}</option>
					</c:otherwise>
				</c:choose>
			</c:forEach>
		 </select>
	     </fieldset>						
	</div>				
	<div class="v-row-left">
		<fieldset style="margin-left: 20px;">
		<legend><spring:message  code="employee.diploma"/></legend>
		<select  style="width:150px;" name="diplomaId">  
           <option value="0"><spring:message  code="all"/></option>          
            <c:forEach items="${bean.diplomas}" var="diploma">
				<c:choose>
					<c:when test="${diploma.diplomaid == bean.diplomaId}">
						<option value="${diploma.diplomaid}" selected="selected">${diploma.name}</option>
					</c:when>
					<c:otherwise>
						<option value="${diploma.diplomaid}">${diploma.name}</option>
					</c:otherwise>
				</c:choose>
			</c:forEach>
		</select>
		</fieldset>
	 </div> 
	 <div class="v-row-left">
		<fieldset style="margin-left: 20px;">
		<legend><spring:message  code="employee.languages"/></legend>
		<select  style="width:150px;" name="language">  
           <option value=""><spring:message  code="all"/></option>          
            <c:forEach items="${bean.languages}" var="language">
				<c:choose>
					<c:when test="${language.name == bean.language}">
						<option value="${language.name}" selected="selected">${language.name}</option>
					</c:when>
					<c:otherwise>
						<option value="${language.name}">${language.name}</option>
					</c:otherwise>
				</c:choose>
			</c:forEach>
		</select>
		</fieldset>
	 </div> 			    		      
	<div class="v-row-right" style="padding-top: 20px;">
		<input class="txt-search" maxLength="100" type="text"  value="${bean.searchKey}" title="Keyword..."
		       style="width: 250px;height: 20px;" name="searchKey" />
		<input type="button" id="searchMembers" class="bt-form" value="<spring:message  code="search"/>" />
	</div>								
</div>            
<div class="v-row" id="v-global-message">
	<c:if test="${addOK == true }">
	<span class="v-global-success-message v-row">
		<span><spring:message  code="project.add.members.success" /></span>
	</span>
	</c:if>
</div>	 
<div class="v-row">								
<div>
<table class="v-table" id="mytable">
    <thead>
      <tr class="v-table-header">
			<th width="40"><spring:message code="title.no" /></th>
			<th width="40"><input class="ckbSelectAll" type="checkbox" /></th>
			<th width="150"><spring:message code="employee.fullname" /></th>
			<th width="100"><spring:message code="employee.visa" /></th>
			<th width="100"><spring:message code="employee.rank" /></th>
			<th width="100"><spring:message code="employee.diploma" /></th>
			<th width="100"><spring:message code="employee.languages" /></th>
			<th width="150" ><spring:message code="employee.function" /></th>
	  </tr>
    </thead>
	<tbody>		
		<c:choose>
			<c:when test="${bean.countList == 0}">
				<tr>
					<td colspan="8" class="v-warning-message">
						<spring:message code="search.empty" />
					</td>
				</tr>
			</c:when>
			<c:otherwise>
				<c:forEach items="${bean.employees}" var="employee" varStatus="count">						
					<tr class="${count.count % 2 != 0 ? 'v-table-row-0' : 'v-table-row-1'}">
					<td scope="row" class="v-number-cell">
					    <c:out value="${count.count + ( bean.paging.currentPage - 1 ) * bean.paging.pageSize}" />								
					</td>
					<td scope="row" class="v-number-cell">
					<spring:bind path="employeeFunctionInProjects[${count.index}].employee.employeeid">												
					    <input type="checkbox"  name="${status.expression}" class="ckbChild" value="${employee.employeeid}"/>	
					</spring:bind>						    														   							   							
					</td>
					<td scope="row" class="v-text-cell">
					   <c:out value="${employee.lastname} ${employee.firstname}" />
					</td>						
					<td scope="row" class="v-text-cell">
					   <c:out value="${employee.visa}" />
					</td>						
					<td scope="row" class="v-text-cell">
					    <c:out value="${employee.rank.name}" />
					</td>						
					<td scope="row" class="v-text-cell">
					    <c:out value="${employee.diploma.name}" />
					</td>
					<td scope="row" class="v-text-cell">
					    <c:out value="${employee.languages}" />
					</td>
					<td scope="row" class="v-text-cell">	
					<spring:bind path="employeeFunctionInProjects[${count.index}].function.functionid">																					
						<select name="${status.expression}" style=" width: 100%;">	
			                <option value="0"><spring:message  code="please.choice"/></option>
					       <c:forEach items="${bean.functions}" var="function">
							  <option value="${function.functionid}">${function.name}</option>
							</c:forEach>					           
						</select>
					</spring:bind>		        
					</td>						  
					</tr>
				  </c:forEach>
			</c:otherwise>
		</c:choose>
		</tbody>
	</table>
</div>
<c:if test="${bean.isAdmin == true && bean.countList > 0}">				
<div class="v-row">
	<br/>
	<div class="v-row-center">
		<span>
		<input type="button" class="bt-form" name="addMembers" id="addMembers" 
			value="<spring:message code="button.add" />" />
		</span>			
		<span>
		<input type="button" class="bt-form"
			onclick="cancel('<c:out value='${bean.returnToFullPageURL }'/>')"
			value="<spring:message code="button.cancel"/>" />
		</span>
	</div>
</div>
</c:if>
<c:if test="${bean.countList > 0}">
  <div class="v-row">
	 <c:set value="${bean.paging}" var="paging"></c:set>
	 <%@ include file="../common/pagination.jsp"%>
  </div>
</c:if>
</div>
